Image by Fauxels from Pexels
Your task in this lab is to improve a plot that violates many data visualization best practices. We want you to get creative and make a visualisation that tells a (much!) better story than the original plot.
Complete the following steps during the workshop with your team.
We will also be going through the steps of how you can working collaboratively in your teams in preparation for your projects. Please read the instructions carefully for who needs to do what and when, and ask a tutor for assistance if you are stuck.
Take 5 minutes to go around the team, each pointing out one error in the following visual.
Once you are done with this, give a number to each team member. If you want to assign numbers at random, you can go to the Random.org sequence generator, and assign the first number that appears to the person whose name is first in the alphabet, and so on. Skip over any numbers that are larger than the size of your team. In this lab, team members will take turns sharing their screen and working on an exercise in the common team repo, commit and push their changes, and then the next team member will take over and pull the changes before they make any further changes to their lab. In the lab instructions you will see markers for
TEAM MEMBER 1:
TEAM MEMBERS 2+:
EVERYONE:
Important: For the next few steps, only one person at a time should be doing the following steps. Everyone else should take their hands off their computer and do not jump ahead! If you come across a problem (specifically a merger conflict) then raise your hand for a tutor to help.
TEAM MEMBER 1:
TEAM MEMBER 2:
OTHER TEAM MEMBERS:
EVERYONE:
Congratulations, you have now started working collaboratively from the same repository in GitHub. This will be extremely useful in your projects for sharing out the workload amongst team members.
GitHub is very smart when merging the repository in GitHub with the updated version you Push from RStudio. Typically, each team member works in different locations in the repository and there should not be any major merger issues. However, each team member in the above instructions are changing the same line in the R Markdown document and so it was important for only one member does their task at any one time. Otherwise you would have created a Merger Conflict (ask a tutor for help if this happens to your team). We will discuss how to resolve merger conflicts in the next lab.
EVERYONE: Before getting started with the Exercises, run the following code in the Console to load this package.
library(tidyverse)The American Association of University Professors (AAUP) is a non-profit membership association of faculty and other academic professionals. This report compiled by the AAUP shows trends in instructional staff employees between 1975 and 2011, and contains an image very similar to the one given below.
EVERYONE: Let’s start by loading the data used to create this plot.
staff <- read_csv("data/instructional-staff.csv")Each row in this dataset represents a faculty type, and the columns are the years for which we have data. The values are percentage of hires of that type of faculty for each year.
## # A tibble: 5 × 12
## facult…¹ `1975` `1989` `1993` `1995` `1999` `2001` `2003` `2005` `2007` `2009`
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Full-Ti… 29 27.6 25 24.8 21.8 20.3 19.3 17.8 17.2 16.8
## 2 Full-Ti… 16.1 11.4 10.2 9.6 8.9 9.2 8.8 8.2 8 7.6
## 3 Full-Ti… 10.3 14.1 13.6 13.6 15.2 15.5 15 14.8 14.9 15.1
## 4 Part-Ti… 24 30.4 33.1 33.2 35.5 36 37 39.3 40.5 41.1
## 5 Graduat… 20.5 16.5 18.1 18.8 18.7 19 20 19.9 19.5 19.4
## # … with 1 more variable: `2011` <dbl>, and abbreviated variable name
## # ¹faculty_type
In order to recreate this visualization we first need to reshape the data to have one variable for faculty type and one variable for year. In other words, we will convert the data from the long format to wide format.
TEAM MEMBER 1 should write the answer to Exercises 1, and then commit and push their changes. Everyone else: participate, help out, but no typing in the R Markdown document and no committing/pushing!
🧶 ✅ ⬆️ At this point TEAM MEMBER 1 should knit the Rmd, stage, commit, and push their changes to GitHub with an appropriate commit message. Make sure to commit and push all changed files so that your Git pane is cleared up afterwards.
TEAM MEMBER 2 should now pull ⬇️ before doing anything else. They should then write the answers to Exercises 2 and 3, and then commit and push their changes. Everyone else: participate, help out, but no typing in the R Markdown document and no committing/pushing!
We do the wide to long conversation using
pivot_longer(). The animation below show how this function
works, as well as its counterpart pivot_wider().
Quick reminder: the function has the following arguments:
pivot_longer(data, cols, names_to = "name")data as usual.cols, specifies the columns to
pivot into longer format.names_to, is the name of the column
where column names of pivoted variables go (character string).values_to is the name of the
column where data in pivoted variables go (character string).staff_long.staff_long <- ___ %>%
___(
cols = ___,
names_to = "___",
values_to = "___"
)staff_long to check if your guess regarding
number of rows from Exercise 1 was correct.🧶 ✅ ⬆️ At this point TEAM MEMBER 2 should knit the Rmd, commit, and push their changes to GitHub with an appropriate commit message. Make sure to commit and push all changed files so that your Git pane is cleared up afterwards.
TEAM MEMBER 3 should now pull ⬇️ before doing anything else. They should then write the answers to Exercises 4 and 5, and then commit and push their changes. Everyone else: participate, help out, but no typing in the R Markdown document and no committing/pushing!
staff_long %>%
ggplot(aes(x = year, y = value, color = faculty_type)) +
geom_line()group aesthetic to the plot (grouping by
faculty_type) and plot again. What does the plot reveal
about instructional staff employment trends over the years?🧶 ✅ ⬆️ At this point TEAM MEMBER 3 should knit the Rmd, commit, and push their changes to GitHub with an appropriate commit message. Make sure to commit and push all changed files so that your Git pane is cleared up afterwards.
TEAM MEMBER 4 should now pull ⬇️ before doing anything else. They should then write the answers to Exercise 6, and then commit and push their changes. Everyone else: participate, help out, but no typing in the R Markdown document and no committing/pushing! (If your team has fewer than 4 people, just move back to the first member.) If there is no TEAM MEMBER 4 then cycle back round to TEAM MEMEBER 1.
🧶 ✅ ⬆️ At this point TEAM MEMBER 4 should knit the Rmd, commit, and push their changes to GitHub with an appropriate commit message. Make sure to commit and push all changed files so that your Git pane is cleared up afterwards.
The next team member should now pull ⬇️ before doing anything else. They should then write the answers to Exercise 7 and 8, and then commit and push their changes. Everyone else: participate, help out, but no typing in the R Markdown document and no committing/pushing! If someone in your team is participating remotely, remember to share screens.
🧶 ✅ ⬆️ At this point the team member should knit the Rmd, commit, and push their changes to GitHub with an appropriate commit message. Make sure to commit and push all changed files so that your Git pane is cleared up afterwards.
Aim to make it to this point during the workshop.
Go back through your write up to make sure you are following coding style guidelines we discussed in class. Make any edits as needed.
Also, make sure all of your R chunks are properly labelled and your figures are reasonably sized.
Once the last person pushes their final changes, others should pull the changes and knit the R Markdown document to confirm that they can reproduce the report.
TEAM MEMBERS 2+: The following steps will ensure that you have your own copy of today’s lab worksheet and maintain all of the communication between RStudio and GitHub so that you can attempt any outstanding exercises on your own time in your own version of the worksheet.
TEAM MEMBERS 1: After today’s lab, you may want to prevent others from making any further changes to the worksheet. - First ensure that your team members have pulled the latest version of the repository. - In the lab worksheet repository on GitHub, go to Settings and then Collaborators. - Remove your team members so that they can no longer push changes to the repository.
Want to see more sad plots?